package kr.hkit.powerjava.chapter22.work;

public class Student implements Comparable<Student>{
	private int stdNum;
	private String stdName;
	private int korScore;
	private int engScore;
	private int mathscore;
	public Student(int stdNum, String stdName) {
		super();
		this.stdNum = stdNum;
		this.stdName = stdName;
	}
	public int getStdNum() {
		return stdNum;
	}
	public void setStdNum(int stdNum) {
		this.stdNum = stdNum;
	}
	public String getStdName() {
		return stdName;
	}
	public void setStdName(String stdName) {
		this.stdName = stdName;
	}
	public int getKorScore() {
		return korScore;
	}
	public void setKorScore(int korScore) {
		this.korScore = korScore;
	}
	public int getEngScore() {
		return engScore;
	}
	public void setEngScore(int engScore) {
		this.engScore = engScore;
	}
	public int getMathscore() {
		return mathscore;
	}
	public void setMathscore(int mathscore) {
		this.mathscore = mathscore;
	}
	public Student(int stdNum, String stdName, int korScore, int engScore,
			int mathscore) {
		super();
		this.stdNum = stdNum;
		this.stdName = stdName;
		this.korScore = korScore;
		this.engScore = engScore;
		this.mathscore = mathscore;
	}
	public int totalScore(){
		return korScore+mathscore+engScore;
	}
	public double totalAvg(){
		return totalScore()/3.0;
	}
	@Override
	public boolean equals(Object obj) {
		return stdNum==((Student)obj).stdNum && 
				stdName.equals(((Student)obj).stdName);
	//	return stdName.equals(((Student)obj).stdName);//이름검색
	}
	@Override
	public String toString() {
		return String
				.format("%3s\t%5s\t%4s\t%4s\t%4s\t%4s\t%4.2f",
						stdNum, stdName, korScore, engScore, mathscore,
						totalScore(), totalAvg());
	}
	@Override
	public int compareTo(Student o) {
		// TODO Auto-generated method stub
		return totalScore()-o.totalScore();
	}
	
}
